<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>

    <title>微信支付样例-支付</title>

</head>
<body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<br/>
<font color="#9ACD32"><b>该笔订单支付金额为<span style="color:#f00;font-size:50px">1分</span>钱</b></font><br/><br/>
<div align="center">
    <button style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" onclick="callpay()" >立即支付</button>
</div>
<div id="pay">123</div>
<script type="text/javascript">
    $(function () {
        var bb=unifiedorder();
       // console.log(aa.responseText);

        //获取支付参数
        // GetPayConfig();

        //  var test=$('<div/>').html('{$jsApiParameters}').text()
        // var aa= JSON.parse(test)
        //
        //  console.log( JSON.parse(test))

    })
    function unifiedorder() {
        $.ajax({
            type: "post",
            url: 'http://yun.8a1.top/api/WeChat/Wxconfig',
            dataType: "json",
            async: false,
            success: function (response) {
                console.log(response)
                return false
                wx.config({
                    debug: true,
                    appId: ' ',
                    timestamp: '',
                    nonceStr: ' ',
                    signature: ' ',
                    jsApiList: [
                    // 所有要调用的 API 都要加到这个列表中
                    'getLocation',
                ]
            });
                wx.ready(function () {
                    wx.checkJsApi({
                        jsApiList: [
                            'getLocation'
                        ],

                        success: function (res) {
                            // alert(JSON.stringify(res));
                            // alert(JSON.stringify(res.checkResult.getLocation));
                            if (res.checkResult.getLocation == false) {
                                alert('你的微信版本太低，不支持微信JS接口，请升级到最新的微信版本！');
                                return;
                            }
                        }
                    });
                    wx.error(function(res){
                        alert("接口调取失败")
                    });
                    wx.getLocation({
                        success: function (res) {
                            alert(JSON.stringify(res));
                        },
                        cancel: function (res) {
                            alert('用户拒绝授权获取地理位置');
                        }
                    });
                });
            }
        });


    }

    //调用微信JS api 支付
    function jsApiCall()
    {

        var test=$('#pay').html()
       // console.log(test)
        var aa= JSON.parse(test).return_msg
        console.log(aa)
        return false
        WeixinJSBridge.invoke(

            'getBrandWCPayRequest', {
                'appId': aa.appId,
                'nonceStr': aa.nonceStr,
                'package': aa.package,
                'signType': aa.signType,
                'timeStamp': aa.timeStamp,
                'paySign': aa.paySign,
            },
            function(res){
                WeixinJSBridge.log(res.err_msg);
                alert(res.err_code+res.err_desc+res.err_msg);
            }
        );
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
</script>

</body>
</html>